package com.xxiongb.business.controller;

import java.util.concurrent.atomic.AtomicLong;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xxiongb.business.bean.Greeting;

@RestController
public class HomeController {
	private static final String template = "Hello, %s!";
    private final AtomicLong counter = new AtomicLong();

	@RequestMapping("/user/greeting")
    public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
		 return new Greeting(counter.incrementAndGet(),
                 String.format(template, name));
	}
	
	
	@RequestMapping("/admin/greeting")
    public Greeting greetingAdmin(@RequestParam(value="name", defaultValue="Admin World") String name) {
		 return new Greeting(counter.incrementAndGet(),
                 String.format(template, name));
	}
}
